/* eslint-disable no-global-assign */
const state = {   // 全局数据区
  count: 1
}

const mutations = {   // setter方法
  add (state,n) {
    state.count += n
  },
  reduce (state) {
    state.count--
  }
}

const getters = {      // getter方法
  getCount: function (state) {
    return state.count
  }
}

const actions = {     // 异步setter调用方法，推荐使用这个
  addAction (context) {
    context.commit('add', 10)
  },
  reduceAction ({commit}) {
    commit('reduce')
  }
}
// 将该部分的数据模块封装并开放出去
export default module = {
  state,
  mutations,
  getters,
  actions
}
